package com.eddie.jdbc.service.impl;

import com.eddie.jdbc.dao.impl.BaseDaoImpl;
import com.eddie.jdbc.entity.AccountEntity;
import com.eddie.jdbc.entity.PetTypeVarietiesMappingEntity;
import com.eddie.jdbc.service.PetTypeVarietiesMappingService;
import com.eddie.jdbc.vo.AccountVo;
import lombok.SneakyThrows;
import org.springframework.beans.BeanUtils;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Map;


/**
 * @author Eddie
 */
public class PetTypeVarietiesMappingServiceImpl extends BaseDaoImpl<PetTypeVarietiesMappingEntity> implements PetTypeVarietiesMappingService {


    @SneakyThrows
    @Override
    public PetTypeVarietiesMappingEntity getPetTypeVarietiesMapping(Long petId) {
        String sql = "select *from %s where pet_id=?".formatted(simpleName);
        PreparedStatement ps = conn.prepareStatement(sql);
        ps.setObject(1, petId);
        ResultSet rs = ps.executeQuery();
        if (rs.next()) {
            PetTypeVarietiesMappingEntity entity = new PetTypeVarietiesMappingEntity();
            getFilelds(rs, entity);
            return entity;
        }
        return null;
    }
}